#!/usr/bin/env python
################################################################################
# subtends.py - A standalone executable wrapper around geomtetry.subtends; it
#               calculates the angle subtended by a pair of (RA,Dec)'s
#

"""
TODO: 
"""

__author__ = 'Adrian Price-Whelan <adrn@astro.columbia.edu>'

# Project Dependencies
import geometry

if __name__ == '__main__':
    import sys, argparse
    
    parser = argparse.ArgumentParser(description="Compute the angle subtended between two sets of coordinates on the surfaces of a sphere.")
    parser.add_argument('coords', metavar='', type=float, nargs='+',\
                        help='Two sets of coordinates, a1 b1 a2 b2')
    parser.add_argument('-u', '--units', dest="units", default="degrees")
    args = parser.parse_args()
    
    if len(args.coords) != 4: raise ValueError("You can only supply 2 sets of coordinates! e.g. subtends A1 B1 A2 B2")
    
    if args.units.lower() == "degrees":
        theta = geometry.subtends(*args.coords, units=args.units)
        print "Angle subtended:", theta.deg, args.units
    elif args.units.lower() == "radians": 
        theta = geometry.subtends(*args.coords, units=args.units)
        print "Angle subtended:", theta.rad, args.units
    else:
        raise ValueError("Units specified, %s, are not valid! Use 'degrees' or 'radians'" % args.units)
    
else:
    raise ImportError("This module is an executable! Not meant to be imported.")